<ui:composition xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:fn="http://java.sun.com/jsp/jstl/functions"
        xmlns:g="http://code.google.com/p/ada-ado/generator"
        xmlns:f="http://java.sun.com/jsf/core">
<h:list value="#{package.queries}" var="query">
  <h:panelGroup rendered="#{not empty query.type}">
<h:panelGroup rendered="#{query.bean eq 'yes'}">
#{''}
   --  --------------------
   --  Get the bean attribute identified by the given name.
   --  --------------------
   overriding
   function Get_Value (From : in #{query.type};
                       Name : in String) return Util.Beans.Objects.Object is
   begin
   <h:list value="#{query.columns}" var="column">
      if Name = "#{column.name}" then
      <h:panelGroup rendered="#{column.type.isInteger or column.type.isIdentifier}">
         return Util.Beans.Objects.To_Object (Long_Long_Integer (From.#{fn:capitalize(column.name)}));
      </h:panelGroup>
      <h:panelGroup rendered="#{column.type.isDate and g:adaType(column,1) ne 'ADO.Nullable_Time'}">
         return Util.Beans.Objects.Time.To_Object (From.#{fn:capitalize(column.name)});
      </h:panelGroup>
      <h:panelGroup rendered="#{column.type.isDate and g:adaType(column,1) eq 'ADO.Nullable_Time'}">
         if From.#{fn:capitalize(column.name)}.Is_Null then
            return Util.Beans.Objects.Null_Object;
         else
            return Util.Beans.Objects.Time.To_Object (From.#{fn:capitalize(column.name)}.Value);
         end if;
      </h:panelGroup>
      <h:panelGroup rendered="#{column.type.isEnum}">
         return #{g:adaType(column)}_Objects.To_Object (From.#{fn:capitalize(column.name)});
      </h:panelGroup>
      <h:panelGroup rendered="#{not column.type.isInteger and not column.type.isEnum and not column.type.isIdentifier and not column.type.isDate}">
         return Util.Beans.Objects.To_Object (From.#{fn:capitalize(column.name)});
      </h:panelGroup>
      end if;
   </h:list>
      return Util.Beans.Objects.Null_Object;
   end Get_Value;
#{''}

   --  --------------------
   --  Run the query controlled by &lt;b&gt;Context&lt;/b> and append the list in &lt;b>Object&lt;/b>.
   --  --------------------
   procedure List (Object  : in out #{fn:capitalize(query.type)}_List_Bean'Class;
                   Session : in out ADO.Sessions.Session'Class;
                   Context : in out ADO.Queries.Context'Class) is
   begin
      List (Object.List, Session, Context);
   end List;
</h:panelGroup>

   --  --------------------
   --  #{query.comment}
   --  --------------------
   procedure List (Object  : in out #{fn:capitalize(query.type)}_Vector;
                   Session : in out ADO.Sessions.Session'Class;
                   Context : in out ADO.Queries.Context'Class) is
      procedure Read (Into : in out #{fn:capitalize(query.type)});
#{''}
      Stmt : ADO.Statements.Query_Statement
          := Session.Create_Statement (Context);
      Pos  : Natural := 0;

      procedure Read (Into : in out #{fn:capitalize(query.type)}) is
      begin
<h:list value="#{query.members}" var="column">
  <h:panelGroup rendered="#{column.type.isIdentifier}">
         Into.#{fn:capitalize(column.name)} := Stmt.Get_Identifier (#{column.index});
  </h:panelGroup>
  <h:panelGroup rendered="#{column.type.isString}">
         Into.#{fn:capitalize(column.name)} := Stmt.Get_Unbounded_String (#{column.index});
  </h:panelGroup>
  <h:panelGroup rendered="#{column.type.isEnum}">
         Into.#{fn:capitalize(column.name)} := #{g:adaType(column)}'Val (Stmt.Get_Integer (#{column.index}));
  </h:panelGroup>
  <h:panelGroup rendered="#{not column.type.isIdentifier and not column.type.isString and not column.type.isEnum}">
         Into.#{fn:capitalize(column.name)} := Stmt.Get_#{fn:capitalize(g:adaType(column,2))} (#{column.index});
  </h:panelGroup>
</h:list>
      end Read;

   begin
      Stmt.Execute;
      #{fn:capitalize(query.type)}_Vectors.Clear (Object);
      while Stmt.Has_Elements loop
         Object.Insert_Space (Before => Pos);
         Object.Update_Element (Index => Pos, Process => Read'Access);
         Pos := Pos + 1;
         Stmt.Next;
      end loop;
   end List;
  </h:panelGroup>
#{''}
</h:list>

#{''}
</ui:composition>
